package cn.itsource.org.controller;

import cn.itsource.common.util.AjaxResult;
import cn.itsource.org.ro.RegisterImgRo;
import cn.itsource.org.ro.RegisterUserPhoneRo;
import cn.itsource.org.service.IRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/register")
public class RegisterController {
    @Autowired
    private IRegisterService registerService;
    /**
     * 获取图片验证码  生成图片验证码
     * @param key
     * @return
     */
    @GetMapping("/verifyCode/image/{key}")
    public AjaxResult verifyCode(@PathVariable("key")String key){
        return registerService.verifyCode(key);
    }

    /**
     * 发送短信验证码
     * @param registerImgRo
     * @return
     */
    @PostMapping("/check/image")
    public AjaxResult checkImage(@RequestBody RegisterImgRo registerImgRo, HttpServletRequest request){
        return registerService.checkImage(registerImgRo);
    }

    @PostMapping("/userPhone")
    public AjaxResult userPhone(@RequestBody @Validated RegisterUserPhoneRo userPhoneRo){
        return registerService.userPhone(userPhoneRo);
    }
}
